package main

import (
	"github.com/kataras/iris"
	"manageCrontab/config"
	"manageCrontab/crontab"
	"manageCrontab/db"
	"manageCrontab/lib"
	"manageCrontab/models"
	"manageCrontab/routes"
)

/*
# 安装rizla包
$ go get -u github.com/kataras/rizla
# 热重启方式启动iris项目
$ rizla main.go
*/

func main() {
	config.InitConfig("")
	db.Init()
	defer lib.RecoverPanicLevel1()
	lib.InitCustomParam()

	// 定时任务
	task := models.Task{}
	task.TaskId = "crontab_run"
	task.TaskType = "run"
	crontab.AddTask(task, "0/5 * * * * ?")
	crontab.Cront.Start()
	crontab.ReStart()
	//go crontab.StopTask()

	app := iris.New()
	routes.Home(app)
	routes.Admin(app)
	app.Run(iris.Addr(":8000"))
}
